package com.example.daummap;

import net.daum.mf.map.api.MapPOIItem;
import net.daum.mf.map.api.MapPoint;
import net.daum.mf.map.api.MapView;
import android.app.Activity;
import android.os.Bundle;
import android.widget.FrameLayout;
import android.widget.TextView;

public class MainActivity extends Activity implements MapView.OpenAPIKeyAuthenticationResultListener, 
MapView.MapViewEventListener,
MapView.CurrentLocationEventListener,
MapView.POIItemEventListener{

	TextView tx_latitude;
	TextView tx_longitude;
	FrameLayout map;
	MapView mapView;
	
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    
        tx_latitude = (TextView) findViewById(R.id.textView1);
        tx_longitude = (TextView) findViewById(R.id.textView2);
        map = (FrameLayout) findViewById(R.id.map);
        
        mapView = new MapView(this);

    	mapView.setDaumMapApiKey("d9519ff7443ba94802551b03117184aae5257797");
    	mapView.setOpenAPIKeyAuthenticationResultListener(this);
    	mapView.setMapViewEventListener(this);
    	mapView.setCurrentLocationEventListener(this);
    	mapView.setPOIItemEventListener(this);

    	mapView.setMapType(MapView.MapType.Standard);
    	
    	map.addView(mapView);
    	
    	mapView.setCurrentLocationEventListener(this);
    	mapView.setCurrentLocationTrackingMode(MapView.CurrentLocationTrackingMode.TrackingModeOnWithHeading);
        
    }

	public void onCalloutBalloonOfPOIItemTouched(MapView arg0, MapPOIItem arg1) {
		// TODO Auto-generated method stub
		
	}

	public void onDraggablePOIItemMoved(MapView arg0, MapPOIItem arg1, MapPoint arg2) {
		// TODO Auto-generated method stub
		
	}

	public void onPOIItemSelected(MapView arg0, MapPOIItem arg1) {
		// TODO Auto-generated method stub
		
	}

	public void onCurrentLocationDeviceHeadingUpdate(MapView arg0, float arg1) {
		// TODO Auto-generated method stub
		
	}

	public void onCurrentLocationUpdate(MapView arg0, MapPoint arg1, float arg2) {
		// TODO Auto-generated method stub
		
	}

	public void onCurrentLocationUpdateCancelled(MapView arg0) {
		// TODO Auto-generated method stub
		
	}

	public void onCurrentLocationUpdateFailed(MapView arg0) {
		// TODO Auto-generated method stub
		
	}

	public void onMapViewCenterPointMoved(MapView mapView, MapPoint point) {

		tx_latitude.setText(Double.toString(point.getMapPointGeoCoord().latitude));
		tx_longitude.setText(Double.toString(point.getMapPointGeoCoord().longitude));
		
	}

	public void onMapViewDoubleTapped(MapView arg0, MapPoint arg1) {
		// TODO Auto-generated method stub
		
	}

	public void onMapViewInitialized(MapView arg0) {
		// TODO Auto-generated method stub
		
	}

	public void onMapViewLongPressed(MapView arg0, MapPoint arg1) {
		// TODO Auto-generated method stub
		
	}

	public void onMapViewSingleTapped(MapView arg0, MapPoint arg1) {
		// TODO Auto-generated method stub
		
	}

	public void onMapViewZoomLevelChanged(MapView arg0, int arg1) {
		// TODO Auto-generated method stub
		
	}

	public void onDaumMapOpenAPIKeyAuthenticationResult(MapView arg0, int arg1, String arg2) {
		// TODO Auto-generated method stub
		
	}

}
